package com.gears_software.sxdc.dccx.ui.util.popu;

import android.app.Activity;
import android.view.View;
import android.view.animation.Animation;
import android.widget.TextView;

import com.gears_software.sxdc.dccx.R;

import razerdp.basepopup.BasePopup;
import razerdp.basepopup.BasePopupWindow;

/**
 * Created by chezhenzhen on 2017/7/27.
 */

public class PhotoPopup extends BasePopupWindow implements View.OnClickListener {

    TextView txt_photograph;
    TextView txt_selectphoto;
    TextView txt_cancel;
    PhotocallBack photocallBack = null;

    public PhotoPopup(Activity context) {
        super(context);
        txt_photograph = (TextView) findViewById(R.id.txt_paizhao);
        txt_selectphoto = (TextView) findViewById(R.id.txt_selectphoto);
        txt_cancel = (TextView) findViewById(R.id.txt_cancel);
        setViewClickListener(this, txt_photograph, txt_selectphoto, txt_cancel);
    }

    @Override
    protected Animation initShowAnimation() {
        return getTranslateAnimation(250 * 2, 0, 300);
    }

    @Override
    public View getClickToDismissView() {
        return getPopupWindowView();
    }

    @Override
    public View onCreatePopupView() {
        return createPopupById(R.layout.popu_photo);
    }

    @Override
    public View initAnimaView() {
        return findViewById(R.id.popup_anima);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.txt_paizhao:
                photocallBack.photoClick(0);
                dismissWithOutAnima();
                break;
            case R.id.txt_selectphoto:
                photocallBack.photoClick(1);
                dismissWithOutAnima();
                break;
            case R.id.txt_cancel:
                dismissWithOutAnima();
                break;
            default:
                break;
        }
    }

    /**
     * 自定义控件的自定义事件
     *
     * @param photocallBack 接口类型
     */
    public void setPhotoClick(PhotocallBack photocallBack) {
        this.photocallBack = photocallBack;
    }

    //自定义一个接口
    public interface PhotocallBack {
        public void photoClick(int photoTag);
    }
}
